package com.lzc.springBootPart;

import org.springframework.core.env.PropertySource;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.support.ResourcePropertySource;

import java.io.IOException;

public class ApplicationEnvironmentTest {

    public static void main(String[] args) throws IOException {
        StandardEnvironment environment = new StandardEnvironment();
        environment.getPropertySources().addFirst(new ResourcePropertySource(new ClassPathResource("application.properties")));
        for (PropertySource<?> propertySource : environment.getPropertySources()) {
            System.out.println(propertySource.getName());
        }
        System.out.println(environment.getProperty("JAVA_HOME"));
        System.out.println(environment.getProperty("server.port"));
    }
}
